package com.itheima.a13;

import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * @author: AirMan
 * @date: 2025/4/14 15:14
 * @description:
 */
public class MyA13 {
    public static void main(String[] args) {

        Target target = new Target();

        MyCGLib proxy = new MyCGLib(new MethodInterceptor() {
            @Override
            public Object intercept(Object p, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
                System.out.println("before...");
//                Object result = method.invoke(target, args);
                Object result = methodProxy.invokeSuper(p, args);
                System.out.println("after...");
                return result;
            }
        });

        proxy.save();
        System.out.println("-------------------------");
        proxy.save(1);
        System.out.println("-------------------------");
        proxy.save(2L);


    }
}
